class testHttp extends egret.DisplayObjectContainer{
	public constructor() {
		super();
		this.addEventListener(egret.Event.ADDED_TO_STAGE,this.createHttp,this);
	}

	private createHttp(){
		var request = new egret.HttpRequest();
		request.responseType = egret.HttpResponseType.TEXT;
		request.open("https://mall.wzgaolaozhuang.com/index.php?s=/api/wxapp/base&wxapp_id=10001&token=0279d21552baa9502fab197ce2bbd73e",egret.HttpMethod.GET);
		request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		request.send();
		request.addEventListener(egret.Event.COMPLETE,this.onGetComplete,this);
		request.addEventListener(egret.IOErrorEvent.IO_ERROR,this.onGetIOError,this);
		request.addEventListener(egret.ProgressEvent.PROGRESS,this.onGetProgress,this);
	}

	private onGetComplete(event:egret.Event):void {
		var request = <egret.HttpRequest>event.currentTarget;
		console.log("get data : ",request.response);
		var responseLabel = new egret.TextField();
		responseLabel.size = 18;
		responseLabel.text = "GET response: \n" + request.response.substring(0, 50) + "...";
		this.addChild(responseLabel);
		responseLabel.x = 50;
		responseLabel.y = 70;
	}

	private onGetIOError(event:egret.IOErrorEvent):void {
		console.log("get error : " + event);
	}

	private onGetProgress(event:egret.ProgressEvent):void {
		console.log("get progress : " + Math.floor(100*event.bytesLoaded/event.bytesTotal) + "%");
	}
	
}